Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddio/lnxmouse.cpp: Code compression using lambdas #653

Closed

Conversation

sebholt
Copy link
Contributor

@sebholt sebholt commented Dec 2, 2024

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

In ddio/lnxmouse.cpp there's a lot of code duplication that differs only by an integer or two. The given patches introduce lambdas that that are called instead of using duplicated inline code. This reduces the code size and helps to avoid errors in duplicated code.

Related Issues

Screenshots (if applicable)

Checklist

  • I have tested my changes locally and verified that they work as intended.
  • I have documented any new or modified functionality.
  • I have reviewed the changes to ensure they do not introduce any unnecessary complexity or duplicate code.
  • I understand that by submitting this pull request, I am agreeing to license my contributions under the project's license.

Additional Comments

…ton down

This compresses repeated code in the sdlMouseButtonDownFilter function
by introducing a lambda that is called with appropriate arguments for each
mouse button press.
…ton up

This compresses repeated code in the sdlMouseButtonUpFilter function
by introducing a lambda that is called with appropriate arguments for each
mouse button release.
This compresses repeated code in the sdlMouseWheelFilter function
by introducing a lambda that is called with appropriate arguments for each
vertical mouse wheel event.
@Lgt2x
Copy link
Member

Lgt2x commented Dec 5, 2024

Does this actually fix anything? I tend to be a little conservative when it comes to refactoring sections of the code that have no issues in the first place, it can sneakily introduce hard to notice problems without real benefits other than DRY-er code.

@sebholt
Copy link
Contributor Author

sebholt commented Dec 8, 2024

It doesn't fix any runtime issue, it's purely code cosmetics. I see how this might introduce unforeseen issues although the changes are not too intrusive. The long term motivation for the changes was to make mouse wheel events first class citizens in the engine and this was a first code cleanup step. But actually I'm too busy to work on that atm so I'm closing this PR.

@sebholt sebholt closed this Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants